/*
 * @Author: your name
 * @Date: 2022-02-10 23:27:24
 * @LastEditTime: 2022-02-10 23:40:56
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \ts\19泛型-类的约束.ts
 */
class BeeKeeper {
    hasMask: boolean;
  }
  
  class ZooKeeper {
    nametag: string;
  }
  
  class Animal {
    numLegs: number;
  }
  
  // 继承animal
  class Bee extends Animal {
    keeper: BeeKeeper;
    // constructor(keeper) {
    //     super()
    //     this.keeper = keeper
    // }
  }
  
  class Lion extends Animal {
    keeper: ZooKeeper;
  }
  
  // 
  function createInstance<A extends Animal>(c: new () => A): A {
      console.log(new c())
    return new c();
  }
  
 
  console.log( createInstance(Lion).keeper)
  createInstance(Bee).keeper;